package byorder;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * LRU Cache
 *
 * Created by JiaJia on 2019/7/22 0022.
 */
public class LeetCode460 {

    public static class LRUCache<K,V> extends LinkedHashMap<K,V>{
        private static final int MAX_ENTRIES=3;
        protected boolean removeEldestEntry(Map.Entry eldest){
            return size()>MAX_ENTRIES;
        }
        LRUCache(){
            super(MAX_ENTRIES,0.75f,true);
        }

    }

    public static void main(String[] args) {
        LRUCache<Integer,String> cache=new LRUCache<Integer, String>();
        cache.put(1,"a");
        cache.put(2,"b");
        cache.put(3,"c");
        cache.get(1);
        cache.put(4,"d");
        System.out.println(cache.keySet());

    }


}